home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1998 June / SGI Freeware 1998 June.iso / dist / fw_metamail.idb / usr / freeware / bin / sun-message.csh.z / sun-message.csh
Linux/UNIX/POSIX Shell Script  |  1998-01-21  |  1KB  |  60 lines

  1. #!/bin/csh -fb
  2. # (The "-fb" might need to be changed to "-f" on some systems)
  3. #
  4. #
  5. # This is sun-message.  It looks at $2 to figure out how to decode $1, then gives the
  6. # user a short menu of choices, display, save, or quit.
  7. #
  8. mkdir /tmp/decode.$$
  9. cd /tmp/decode.$$
  10.  
  11. if ($2 == "uuencode") then
  12.     uudecode $1
  13.  
  14.     echo "The following file was uudecoded:"
  15.     echo ""
  16.  
  17.     set defans = "1"
  18.     while (1)
  19.     ls -l
  20.     set fn = *
  21.  
  22.     echo ""
  23.     echo "Please choose one:"
  24.     echo ""
  25.     echo "1 -- Display it as ASCII text"
  26.     echo "2 -- Save it as a file"
  27.     echo "3 -- Quit this menu"
  28.     echo ""
  29.     echo -n "Which do you prefer (1 - 3)? [$defans] "
  30.  
  31.     set ans = $< 
  32.     if (x$ans == x) then
  33.         set ans = $defans
  34.     endif
  35.     if ($ans == 3)  then
  36.         rm $1
  37.         cd /tmp; /bin/rm -rf /tmp/decode.$$
  38.         exit 0
  39.     else if ($ans == 1) then
  40.         more $fn
  41.     else if ($ans == 2) then
  42.         set nfn = ""
  43.         echo -n "Save as: $HOME/"
  44.         set nfn = $<
  45.         if (x$nfn != x) then
  46.         /bin/cp $fn ${HOME}/$nfn
  47.         else
  48.         echo "Not Saved."
  49.         endif
  50.     else
  51.         echo "Invalid choice."
  52.     endif
  53.     set defans = "3"
  54.     end
  55. else
  56.     more $1
  57. endif
  58.  
  59.  
  60.